<!DOCTYPE HTML>
<html th:with="title='编辑用户'" >
<head th:include="fragments/header :: header">
</head>
<body id="app">
<div class="page-container">
	<form class="form form-horizontal" id="user-form">
		<input type="hidden" name="id" v-model="user.id" />
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>旧密码：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="password"  class="input-text size-S" id="oldpassword" name="oldpassword">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>新密码：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="password"  class="input-text size-S" id="password" name="password">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认新密码：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="password" class="input-text size-S" id="truepassword" name="truepassword">
			</div>
		</div>	
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary size-S radius" type="submit" value="提交">
			</div>
		</div>
	</form>
</div>

<script type="text/javascript">
$(function(){	
	$("#user-form").validate({
		rules:{
			oldpassword:{
				required:true,
				maxlength:16
			},
			password:{
				required:true,
				maxlength:16
			},
			truepassword:{
				required:true,
			    equalTo: "#password"
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$.ajax({
			    type: "POST",
			    url: '/security/user/changePassword',
			    data: $('#user-form').serialize(),
			    error: function(request) {
			    	layer.alert("系统出错");
			    },
			    success: function(data) {
			    	if(data == "修改成功"){
			    		layer.alert(data+"，请关闭当前窗口");
			    	}
			    	if(data == "密码不正确"){
			    		layer.alert(data+"，请重新输入");
			    	}
			    }
			});
		}
	});
});
</script> 
</body>
</html>